package com.pcitc.paas.feign.demo.api;

import com.pcitc.paas.feign.demo.api.annotation.RequestObject;
import com.pcitc.paas.feign.demo.api.model.Person;
import feign.Response;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * description: <br>
 * createTime: 2021/6/21 17:45 <br>
 *
 * @author zzh
 */
@RequestMapping({"/provider"})
public interface ProviderApi {
    @GetMapping({"/test1"})
    String test1(@RequestParam(value = "test",required = false) String test, @RequestParam(value = "flag",required = false) boolean flag, @RequestObject Person person);

    @PostMapping(
            value = {"/test2"},
            consumes = {"application/json"}
    )
    String test2(@RequestParam(value = "test",required = false) String test, @RequestParam(value = "flag",required = false) boolean flag, @RequestBody Person person);

    @PostMapping(
            value = {"/testRequestBody"},
            consumes = {"application/json"}
    )
    String testRequestBody(@RequestBody Person person);

    @GetMapping({"/testPathVariable/{test}"})
    String testPathVariable(@PathVariable String test, @RequestParam(value = "name",required = false) String name);

    @PostMapping(
            value = {"/testUpload1"},
            consumes = {"multipart/form-data"}
    )
    String testUpload1(@RequestParam(value = "test",required = false) String test, @RequestPart("file") MultipartFile file);

    @PostMapping(
            value = {"/testUpload2"},
            consumes = {"multipart/form-data"}
    )
    String testUpload2(@RequestParam(value = "test",required = false) String test, @RequestPart("file") MultipartFile[] file);

    @RequestMapping({"/testDownload1"})
    ResponseEntity<byte[]> testDownload1(@RequestParam(value = "test",required = false) String test);

    @RequestMapping({"/testDownload2"})
    ResponseEntity<byte[]> testDownload2(@RequestParam(value = "test",required = false) String test);

    @RequestMapping({"/testDownload3"})
    Response testDownload3(@RequestParam(value = "test",required = false) String test);
}
